<?php
if(!(@$_COOKIE['name'])){
    echo "<script>alert('请先登录！');window.location.href='/home/login.php'</script>";
}
require('../public/function.php');
connection('blog');
$username=$_COOKIE['name'];
$id=$_GET['id'];
$content=isset($_GET['gg'])?$_GET['gg']:'';
$ctime=date('Y-m-d H:i:s');
$rt="insert into pinglun(author,content,ctime,pid) values('$username','$content','$ctime','$id')";
$jieguo=mysql_query($rt);
if($jieguo){echo "<script>alert('评论成功！');window.location.href='/home/single.php?id=$id'</script>";
}else{
    echo "<script>alert('评论失败！');window.location.href='/home/single.php?id=$id'</script>";
}



?>